package sample.plugin.di.custom;

import com.qiplat.open.ui.widget.dialog.QiBottomDialog;
import com.rapid.api.ext.framework.BaseObject;
import com.rapid.api.framework.project.primary.ProjectLifecycleEvent;
import com.rapid.api.project.Project;
import com.rapid.api.project.ProjectManager;
import com.rapid.framework.extension.annotation.Import;
import com.rapid.framework.extension.annotation.Qualifier;

/**
 * 这是个随意写的类
 * 该类演示注入自定的对象
 */
public class CustomInject extends BaseObject implements ProjectLifecycleEvent {
    //装配自己定义的TestService(其他插件也可以使用)
    @Import
    private TestService testService;

    @Import
    private Teacher teacher;

    @Import
    @Qualifier("stu1")
    private Student student1;

    @Import
    @Qualifier("stu2")
    private Student student2;

    @Override
    public void beforeLoadingProject(Project project, ProjectManager<?> projectManager) {

    }

    @Override
    public void afterLoadingProject(Project project, ProjectManager<?> projectManager) {
        runUI(() -> {
            String message = "成功装配：\n";
            message += testService + "\n\n";
            message += teacher + "\n\n";
            message += student1 + "\n\n";
            message += student2 + "\n\n";
            QiBottomDialog.show(
                    getActivity(),
                    getClass().getSimpleName(),
                    message
            );
        });
    }

    @Override
    public void onCloseProject(Project project, ProjectManager<?> projectManager) {

    }
}
